package com.jason.rxjavatest.retrofit.bean;

import com.jason.rxjavatest.retrofit.interf.PhoneService;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @Author: Jason
 * @Date: 16/5/25
 * @Time: 17:06
 */

public class PhoneAPI {

    public static final String BASE_URL = "http://apis.baidu.com";
    public static final String API_KEY = "38968eec52b83bff5f05e423a1b5d203";

    private PhoneService mPhoneService;

    private PhoneAPI() {

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        mPhoneService = retrofit.create(PhoneService.class);

    }

    public static PhoneAPI getApi() {
        return ApiHolder.phoneAPI;
    }

    static class ApiHolder {
        private static PhoneAPI phoneAPI = new PhoneAPI();
    }

    public PhoneService getPhoneService() {
        return mPhoneService;
    }







}
